package com.peza.bikelog.common.domain.polar;

import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

import com.peza.bikelog.common.util.Util;

public class HrmHrZones implements Writable {

	
	private static Util util = Util.getInstance();
	
	private int zone1;
	private int zone2;
	private int zone3;
	private int zone4;
	private int zone5;
	private int zone6;
	private int zone7;
	private int zone8;
	private int zone9;
	private int zone10;
	private int zone11;
	
	public HrmHrZones(){}
	
	public HrmHrZones(String data){
		List<String>lines = Arrays.asList(data.split("\n"));
		Iterator<String> iter = lines.iterator();
		
		while(iter.hasNext()){
			setZone1(util.convertToInt(iter.next()));
			setZone2(util.convertToInt(iter.next()));
			setZone3(util.convertToInt(iter.next()));
			setZone4(util.convertToInt(iter.next()));
			setZone5(util.convertToInt(iter.next()));
			setZone6(util.convertToInt(iter.next()));
			setZone7(util.convertToInt(iter.next()));
			setZone8(util.convertToInt(iter.next()));
			setZone9(util.convertToInt(iter.next()));
			setZone10(util.convertToInt(iter.next()));
			setZone11(util.convertToInt(iter.next()));
			
		}
		
	}
	
	
	
	public int getZone1() {
		return zone1;
	}
	public void setZone1(int zone1) {
		this.zone1 = zone1;
	}
	public int getZone2() {
		return zone2;
	}
	public void setZone2(int zone2) {
		this.zone2 = zone2;
	}
	public int getZone3() {
		return zone3;
	}
	public void setZone3(int zone3) {
		this.zone3 = zone3;
	}
	public int getZone4() {
		return zone4;
	}
	public void setZone4(int zone4) {
		this.zone4 = zone4;
	}
	public int getZone5() {
		return zone5;
	}
	public void setZone5(int zone5) {
		this.zone5 = zone5;
	}
	public int getZone6() {
		return zone6;
	}
	public void setZone6(int zone6) {
		this.zone6 = zone6;
	}
	public int getZone7() {
		return zone7;
	}
	public void setZone7(int zone7) {
		this.zone7 = zone7;
	}
	public int getZone8() {
		return zone8;
	}
	public void setZone8(int zone8) {
		this.zone8 = zone8;
	}
	public int getZone9() {
		return zone9;
	}
	public void setZone9(int zone9) {
		this.zone9 = zone9;
	}
	public int getZone10() {
		return zone10;
	}
	public void setZone10(int zone10) {
		this.zone10 = zone10;
	}

	public int getZone11() {
		return zone11;
	}

	public void setZone11(int zone11) {
		this.zone11 = zone11;
	}

	@Override
	public String toFileString() {
		StringBuffer buffer = new StringBuffer("[HRZones]\n");
		Field [] fields = this.getClass().getDeclaredFields();
		for (Field field : fields){
			if (field.getName().startsWith("zone")){
				try {
					buffer.append(field.getInt(this)+"\n");
				} catch (IllegalArgumentException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (IllegalAccessException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
		buffer.append("\n");
		return buffer.toString();
	}
	
	
}
